﻿using System;
using System.Collections.Generic;

namespace AvantGameMachine.Graphics.InternalObjects
{
    public class DebugVars : IRenderizableObject
    {
        private Dictionary<string, TextRenderObject> objs = new Dictionary<string, TextRenderObject>();
        private Font font = null;
        private float y;

        public DebugVars()
        {
        }

        internal void Init(Font _font)
        {
            font = _font;
            y = ConvertPointsToProjectionY(0);
        }

        internal void SetVar(string _name, string _value)
        {
            TextRenderObject obj;
            bool result = objs.TryGetValue(_name,out obj);
            if (!result)
            {
                obj = this.CreateNew<TextRenderObject>(_name);
                obj.TextFont = font;
            }

            obj.Text = _name + ":  " +_value;

            if (!result)
            {
                obj.View = TextView.ViewTop;
                obj.Alignement = TextAlignement.AlignementLeft;
                obj.AlignedPosX = ConvertPointsToProjectionX(0);
                obj.PositionY += y;
                y -= obj.TextFont.FontSize.Heightf;
                objs[_name] = obj;
            }
        }
    }
}
